package com.huaxin.hxenum.validator;

import com.huaxin.hxenum.enums.DataQuality;
import com.huaxin.hxenum.validation.ValidDataQuality;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class DataQualityValidator implements ConstraintValidator<ValidDataQuality, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        // 允许 null 或空值通过（由 @NotNull 或 @NotBlank 控制）
        if (value == null || value.trim().isEmpty()) {
            return true;
        }
        return DataQuality.isValid(value);
    }
}